var app = getApp();

Page({
    data: {
        submitbtn: !0,
        state: "",
        f_id: "",
        over: !1,
        pfover:!1,
        openid: "",
        b_id: "",
        b_mid: "",
        widths: 300,
        heigths: 400,
        jobday:0,
        starCheckedImgUrl: "/hyb_jianzhi/images/start.png",
        starUnCheckedImgUrl: "/hyb_jianzhi/images/start_null.png",
        jianzhi_type:[{
            'jz_name':'未录用',
            'jz_index':2,
            'jz_type':'gf'
        },{
            'jz_name':'已录用',
            'jz_index':3,
            'jz_type':'pmsj'
        }],
        current: 0,
    starMap: [
      '差',
      '一般',
      '良好',
      '很好',
      '非常好',
    ],
    evaluations: [
      {
        id: 0,
        name: "兼职表现",
        image: "https://s1.ax1x.com/2018/08/05/PDMaCV.png",
        star: 3,
        note: "良好"
      }
    ],
    starMoney:3,
    starMoneys:'100%'
    },
    getMoney: function(t) {
        var e = this, i = t.detail.value.money, n = (e.data.openid, wx.getStorageSync("openid"), 
        t.detail.value.b_id), o = t.detail.value.b_mid;
        e.setData({
            submitbtn: !1
        }), app.util.request({
            url: "entry/wxapp/Shangjiainfo",
            data: {
                openid: wx.getStorageSync("openid")
            },
            success: function(a) {
                app.util.request({
                    url: "entry/wxapp/Yongjin",
                    data: {
                        money: i,
                        b_id: n,
                        b_mid: o
                    },
                    success: function(t) {
                        a.data.data.s_money - i - t.data.data < 0 ? (wx.showToast({
                            title: "余额不足请充值",
                            image: "/hyb_jianzhi/images/errors.png"
                        }), setTimeout(function() {
                            wx.navigateTo({
                                url: "/hyb_jianzhi/chongzhi/chongzhi"
                            });
                        }, 1e3)) : app.util.request({
                            url: "entry/wxapp/Jiesuan",
                            data: {
                                money: i,
                                b_id: n,
                                b_mid: o
                            },
                            success: function(t) {
                                wx.showToast({
                                    title: "结算成功"
                                }), setTimeout(function() {
                                    wx.navigateTo({
                                        url: "/hyb_jianzhi/shop_apply_detail/shop_apply_detail?f_id=" + e.data.f_id + "&state=" + e.data.state
                                    });
                                }, 1e3);
                            }
                        });
                    }
                });
            }
        });
    },
    hdljisuan:function(a){
        var self = this;
        var f_id = a.currentTarget.dataset.f_id,b_id=a.currentTarget.dataset.b_id;
        app.util.request({
               url: "entry/wxapp/Jiesuan",
               data: {
                       b_id: b_id,
                       b_mid: f_id
                    },
                success: function(t) {
                    wx.showToast({
                        title: "结算成功"
                         }), setTimeout(function() {
                              self.getBaomingxq(self.data.f_id, self.data.state)
                           }, 1e3);
                            }
                        });
    },
    onLoad: function(t) {
        var a = this, e = t.f_id, i = t.state,td=t.days;
        a.setData({
            state: i,
            f_id: e,
            jobday:td
        }), a.getBase(), a.getBaomingxq(e, i);
    },
     callPhone: function(t) {
        this.getform(t.detail.formId), wx.makePhoneCall({
            phoneNumber: t.currentTarget.dataset.phone
        });
    },
    getBase: function() {
        var a = this;
        app.util.request({
            url: "entry/wxapp/Base",
            success: function(t) {
                a.setData({
                    base: t.data.data
                });
            }
        });
    },
    navTab: function(a) {
        var t = this;
        // t.getform(a.detail.formId);
        var e = a.currentTarget.dataset.index;
        var ste = a.currentTarget.dataset.state
        t.setData({
            current: e
        }),
        t.getBaomingxq(t.data.f_id, ste);
    },
    payMoney: function(t) {
        var a = t.detail.value * this.data.base.jiesuan;
        a = a.toFixed(2), this.setData({
            values: t.detail.value,
            pay: a
        });
    },
    getBaomingxq: function(t, a) {
        var e = this;
        app.util.request({
            url: "entry/wxapp/Baomingxq",
            data: {
                state: a,
                f_id: t
            },
            success: function(t) {
                console.log("list"+t.data.data), e.setData({
                    list: t.data.data
                });
            }
        });
    },

  /**
   * 评分
   */
  chooseStar: function (e) {
    var self = this;
    const index = e.currentTarget.dataset.index;
    const star = e.target.dataset.star;
    let evaluations = self.data.evaluations;
    let evaluation = evaluations[index];
    evaluation.star = star;
    evaluation.note = self.data.starMap[star-1];
    self.setData({
      evaluations: evaluations,
      starMoney:star
    });
    self.getStartMonry(self.data.starMoney)
  },
  getStartMonry:function(t){
      var self = this;
      if(t>=3){
          self.setData({
            starMoneys:'100%'
          })
      }else if(t==2){
        self.setData({
            starMoneys:'90%'
          })
      }else{
        self.setData({
            starMoneys:'80%'
          })
      }
  },
  inputClick:function(a){
    var self = this,jobdays = a.detail.value;
    console.log(self.data.jobday)
    if( jobdays > self.data.jobday){
        wx.showToast({
           title: "大于活动天数!",
           success: function() {
            self.setData({
               jobday:self.data.jobday
               })
           }
       })
    }
  },
  hdlJobComment:function(a){
    var self = this;
    app.util.request({
            url: "entry/wxapp/Job_comment",
            data: {
                b_id: self.data.b_id,
                star: self.data.starMoney
            },
            success: function(t) {
                 app.util.request({
               url: "entry/wxapp/Jiesuan",
               data: {
                       b_id: self.data.b_id,
                       b_mid: self.data.f_id
                    },
                success: function(t) {
                    wx.showToast({
                        title: "结算成功"
                         }), setTimeout(function() {
                              self.setData({
                                 over: !1,
                                 pfover:!1,
                              });
                              self.getBaomingxq(self.data.f_id, self.data.state);
                           }, 1e3);
                            }
                        });
            }
        });
  },
    previewClick: function(t) {
        var a = t.currentTarget.dataset.b_openid, e = t.currentTarget.dataset.f_id, i = t.currentTarget.dataset.b_id;
        wx.navigateTo({
            url: "/hyb_jianzhi/preview/preview?b_openid=" + a + "&f_id=" + e + "&b_id=" + i
        });
    },
    reviewWork: function(t) {
        var a = t.currentTarget.dataset.b_openid, e = t.currentTarget.dataset.f_id, i = t.currentTarget.dataset.b_id;
        wx.navigateTo({
            url: "/hyb_jianzhi/review_work/review_work?b_openid=" + a + "&f_id=" + e + "&b_id=" + i
        });
    },
    dklist:function(t){
        var self = this;
        var a = t.currentTarget.dataset.b_openid, e = t.currentTarget.dataset.f_id;
        wx.navigateTo({
            url: "/hyb_jianzhi/dklist/dklist?b_openid=" + a + "&f_id=" + e
        });
    },
    Luyong: function(t) {
        var a = this;
        console.log(t.detail.formId);
        var e = t.currentTarget.dataset.b_id;
        app.util.request({
            url: "entry/wxapp/Luyong",
            data: {
                b_id: e,
                formId: t.detail.formId
            },
            success: function(t) {
                console.log(t), a.getBaomingxq(a.data.f_id, a.data.state);
            }
        });
    },
    lockWork:function(t){
        var self = this,a = t.currentTarget.dataset.b_openid, e = t.currentTarget.dataset.f_id,i = t.currentTarget.dataset.b_id;
        wx.navigateTo({
            url: "/hyb_jianzhi/myworks/myworks?b_openid=" + a + "&f_id=" + e + "&b_id=" + i+"&type=shop"
        });
    },
    Buluyong: function(t) {
        var a = this, e = t.currentTarget.dataset.b_id;
        app.util.request({
            url: "entry/wxapp/Buluyong",
            data: {
                b_id: e,
                formId: t.detail.formId
            },
            success: function(t) {
                a.getBaomingxq(a.data.f_id, a.data.state);
            }
        });
    },
    callPhone: function(t) {
        wx.makePhoneCall({
            phoneNumber: t.currentTarget.dataset.phone
        });
    },
    daogang: function(t) {
        var a = this, e = t.currentTarget.dataset.b_id;
        app.util.request({
            url: "entry/wxapp/Daogang",
            data: {
                b_id: e
            },
            success: function(t) {
                a.getBaomingxq(a.data.f_id, a.data.state);
            }
        });
    },
    jiesuan: function(t) {
        this.setData({
            over: !0,
            openid: t.currentTarget.dataset.openid,
            b_id: t.currentTarget.dataset.b_id,
            b_mid: t.currentTarget.dataset.b_mid
        });
    },
    pflist:function(t) {
        var self = this;
        self.setData({
            pfover: !0,
            openid: t.currentTarget.dataset.b_openid,
            b_id: t.currentTarget.dataset.b_id,
            b_mid: t.currentTarget.dataset.f_id
        });
        
    },
    hideClick: function() {
        this.setData({
            over: !1,
            pfover:!1,
        });
    },
    remove: function(t) {},
    onReady: function() {},
    onShow: function() {
        this.setData({
            over: !1,
            pfover:!1,
            submitbtn: !0
        }), this.getBaomingxq(this.data.f_id, this.data.state);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});